<template>
  <keep-alive>
    <div class="content">
      <nav-title title="入职信息采集" :routerLink = "routerLink"/>
      <folding title="基本信息" :is-add="false" @feedback="setIsShowType">
        <div class="normal-info" @click="toBasic('first')">
          <infor-line title="姓" :important="true" v-bind:value="bsinfo.lastName"></infor-line>
          <infor-line title="名" :important="true" v-bind:value="bsinfo.firstName"></infor-line>
          <infor-line title="姓名拼音" :important="true" v-bind:value="bsinfo.nameAc"></infor-line>
          <infor-line title="性别" :important="true" v-bind:value="bsinfo.sexValue"></infor-line>
          <infor-line title="国籍" :important="true" v-bind:value="bsinfo.countryValue" :arrow="true"></infor-line>
          <infor-line title="出生日期" :important="true" v-bind:value="bsinfo.birthdate"></infor-line>
          <infor-line title="民族" :important="true" v-bind:value="bsinfo.ethnicGrpCdValue" :arrow="true"></infor-line>
          <infor-line title="籍贯" :important="true" v-bind:value="bsinfo.nativePlaceChn"></infor-line>
         
          <infor-line title="最高学历" :important="true" v-bind:value="bsinfo.highestEducLvlValue" :arrow="true"></infor-line>
          <infor-line title="最高学位" :important="true" v-bind:value="bsinfo.cDegreeValue" :arrow="true"></infor-line>
          <infor-line title="专业" :important="true" v-bind:value="bsinfo.cMajor"></infor-line>
          <infor-line title="就学类型" :important="true" v-bind:value="bsinfo.cTolType2Value"></infor-line>
          <infor-line title="毕业类型" :important="true" v-bind:value="bsinfo.cGraTypeValue"></infor-line>
          <infor-line title="毕业院校" :important="true" v-bind:value="bsinfo.cSchool"></infor-line>
          <infor-line title="学制（年）" :important="true" v-bind:value="bsinfo.cSchoolSystem"></infor-line>
          <infor-line title="毕业时间" :important="true" v-bind:value="bsinfo.graEndDt"></infor-line>
          <infor-line title="第二专业" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.secMajor"></infor-line>
          <infor-line title="技术职称" :important="true" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.zcJszc"></infor-line>
          <infor-line title="职称等级" :important="true" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.cPfqTypeValue"></infor-line>
          <!-- <infor-line title="大学生届数" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.stuNum"></infor-line> -->
          <infor-line title="入职来源" :important="true" v-bind:value="bsinfo.cEmplFromValue"></infor-line>
          <infor-line title="推荐人" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.perTjr"></infor-line>
          <infor-line title="参加工作日期" :important="true" v-bind:value="bsinfo.startDtChn"></infor-line>
          <infor-line title="婚姻状况" :important="true" v-bind:value="bsinfo.marStatusValue" :arrow="true"></infor-line>
          <infor-line title="政治面貌" :important="true" v-bind:value="bsinfo.politicalStaChnValue" :arrow="true"></infor-line>
          <infor-line title="集体户口" :value="bsinfo.jtHukou == 'Y' ? '是' : (bsinfo.jtHukou == 'N' ? '否' : '')"></infor-line>
          <infor-line title="户口性质" :important="true" v-bind:value="bsinfo.cHukTypeValue"></infor-line>
          <infor-line title="证件类型" :important="true" v-bind:value="bsinfo.nationalIdTypeValue"></infor-line>
          <infor-line title="证件号码" :important="true" v-bind:value="bsinfo.nationalId"></infor-line>
          <infor-line title="证件过期日期" :important="true" v-bind:value="bsinfo.natExperDt"></infor-line>
          <infor-line title="有无驾照"  v-if="bsinfo.platLx== '10'" :arrow="true" :value="bsinfo.isJiazhao == 'Y' ? '有' : (bsinfo.isJiazhao == 'N' ? '无' : '')"></infor-line>
          <infor-line title="驾照开始日期" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.jiaZhaoDt1"></infor-line>
          <infor-line title="驾照结束日期" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.jiaZhaoDt2"></infor-line>
          <infor-line title="行驶证日期" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.xingshizDt"></infor-line>
          <infor-line title="档案编号" v-bind:value="bsinfo.perDabh"></infor-line>
          <infor-line title="户籍地址" :important="true" v-bind:value="bsinfo.addresslong1"></infor-line>
          <infor-line title="爱心基金成员" v-if="bsinfo.platLx== '10'"  :value="bsinfo.yn == 'Y' ? '是' : (bsinfo.isJiazhao == 'N' ? '否' : '')"></infor-line>
          <infor-line title="入会时间" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.perRhdt"></infor-line>
          <infor-line title="家庭地址" :important="true" v-bind:value="bsinfo.addresslong3"></infor-line>
          <infor-line title="是否住宿" v-if="bsinfo.platLx== '10'"  :value="bsinfo.yn2 == 'Y' ? '是' : (bsinfo.yn2 == 'N' ? '否' : '')"></infor-line>
          <infor-line title="是否外租房" v-if="bsinfo.platLx== '10'" :value="bsinfo.yn3 == 'Y' ? '是' : (bsinfo.yn3 == 'N' ? '否' : '')" ></infor-line>
          <infor-line title="住宿地址" v-if="bsinfo.platLx== '10'" v-bind:value="bsinfo.addresslong2"></infor-line>
         </div>
      </folding>
      <folding title="联系信息" @feedback="setIsShowType" :is-add="false">
        <div class="normal-info" @click="toContact()">
          <infor-line title="手机号码" :important="true" v-bind:value="bsinfo.phone"></infor-line>
          <infor-line title="传真" v-bind:value="bsinfo.cFax" v-if="bsinfo.platLx== '10'"></infor-line>
          <infor-line title="个人Email" v-bind:value="bsinfo.emailAddr" v-if="bsinfo.platLx== '10'"></infor-line>
          <infor-line title="公司电话" v-bind:value="bsinfo.phone2" v-if="bsinfo.platLx== '10'"></infor-line>
          <infor-line title="紧急联系人姓名" :important="true" v-bind:value="bsinfo.emeContract"></infor-line>
          <infor-line title="与本人关系" :important="true" v-bind:value="bsinfo.cRelationFamValue"></infor-line>
          <infor-line title="紧急联系人电话" :important="true" v-bind:value="bsinfo.emePhone"></infor-line>
        </div>
      </folding>
      
      <folding title="亲属信息" @feedback="setIsShowType" :is-add="true" where-is="family" v-if="bsinfo.platLx== '10'">
        <div  v-for="(item) in famVal" class="repeat-info" v-bind:key="item" @click="toFamily(item)">
          <infor-line title="亲属关系" :important="true" v-bind:value="item.cRelationFamValue"></infor-line>
          <infor-line title="亲属姓名" :important="true" v-bind:value="item.cName"></infor-line>
          <infor-line title="工作地点" :important="true" v-bind:value="item.cLocationDescr"></infor-line>
          <infor-line title="手机号" :important="true" :noborder="true" v-bind:value="item.cPhone"></infor-line>
        </div>
      </folding>
      <folding title="教育经历" @feedback="setIsShowType" :is-add="true" where-is="education" v-if="bsinfo.platLx== '10'">
        <div class="timeline-info">
          <div class="tl-item" v-for="(item, index) in eduif" v-bind:key="item">
            <div class="tl-data" @click="toEdu(item)">
              <img class="star" v-if="index%2 === 0" src="./image/star-green.png" alt="">
              <img class="star" v-else src="./image/star-blue.png" alt="">
              <div class="tl-interval">{{item.startDt}} - {{item.endDt}}</div>
              <div>{{(item.cSchool == '其他' && item.cSchoolOth) ? item.cSchoolOth: item.cSchool}}</div>
              <div>{{item.cMajor}}</div>
              <div>{{item.cEducitonValue}}    |     {{item.cDegreeValue}}</div>
            </div>
            <div class="tl-arrow"><img src="./image/u252.png" alt=""></div>
          </div>
        </div>
      </folding>
      <folding title="职称经历" @feedback="setIsShowType" :is-add="true" where-is="qualification" v-if="bsinfo.platLx== '10'">
        <div class="timeline-info">
          <div class="tl-item" v-for="(item, index) in zgzVal" v-bind:key="item">
            <div class="tl-data" @click="toquality(item)">
              <img class="star" v-if="index%2 === 0" src="./image/star-green.png" alt="">
              <img class="star" v-else src="./image/star-blue.png" alt="">
              <div class="tl-interval">{{item.cName}}[<span style="color:red">{{item.cDate}}评定</span>]</div>
              <div>{{item.cPfqTypeValue}}           {{item.cZsbh}} </div>
              <div>评定机构： {{item.cCompany}}</div>
            </div>
            <div class="tl-arrow"><img src="./image/u252.png" alt=""></div>
          </div>
        </div>
      </folding>
      <folding title="工作经历" @feedback="setIsShowType" where-is="theCompanyBefore" v-if="bsinfo.platLx== '10'">
        <div class="timeline-info">
          <div class="tl-item" v-for="(item, index) in expwVal" v-bind:key="item" >
            <div class="tl-data" @click="toWorkExp(item)">
              <img class="star" v-if="index%2 === 0" src="./image/star-green.png" alt="">
              <img class="star" v-else src="./image/star-blue.png" alt="">
              <div class="tl-interval">
                {{item.startDt}} - {{item.endDt}}
              </div>
              <div>{{item.cCompany}}</div>
              <div>{{item.cPosition}}</div>
            </div>
          </div>
        </div>
      </folding>
      <folding title="外语能力" @feedback="setIsShowType" :is-add="true" where-is="language" v-if="bsinfo.platLx== '10'">
        <div  v-for="(item) in lanVal" class="repeat-info" v-bind:key="item" @click="toLang(item)">
          <infor-line title="语言" :important="true" v-bind:value="item.rsLangCdValue"></infor-line>
          <infor-line title="外语证书" v-bind:value="item.cDescr"></infor-line>
          <infor-line title="熟练度" v-bind:value="item.cLangLvValue"></infor-line>
        </div>
      </folding>

      
      <folding title="档案信息" @feedback="setIsShowType" :is-add="false" v-if="bsinfo.platLx== '10'">
        <div class="normal-info" @click="toOutf()">
          <infor-line title="机构联系人" v-bind:value="outf.cOutfMgtAttn"></infor-line>
          <infor-line title="联系电话" v-bind:value="outf.cOutfMgtTel"></infor-line>
          <infor-line title="管理机构" v-bind:value="outf.cOutfNowMgtOrg"></infor-line>
          <infor-line title="档案现所在地" v-bind:value="outf.cOutfNowPlace"></infor-line>
          <infor-line title="报到证主体公司" v-bind:value="outf.cRegCertComp"></infor-line>
          <infor-line title="档案原所在地" v-bind:value="outf.cOutfOrigPlace"></infor-line>
          <infor-line title="档案调入时间" v-bind:value="outf.cOutfXferInDt"></infor-line>
          <infor-line title="档案调出时间" v-bind:value="outf.cOutfXferOutDt"></infor-line>
        </div>
      </folding>

      <folding title="竞业协议信息" @feedback="setIsShowType" :is-add="false" v-if="bsinfo.platLx== '10'">
        <div class="normal-info" @click="toJyxy()">
          <infor-line title="是否签署协议" :value="jyxy.cIsJyxy == 'Y' ? '是' : (jyxy.cIsJyxy == 'N' ? '否' : '')"></infor-line>
          <infor-line title="协议是否有效" :value="jyxy.cIsJyxyStatus == 'Y' ? '是' : (jyxy.cIsJyxyStatus == 'N' ? '否' : '')"></infor-line>
          <infor-line title="化名" :value="jyxy.cNameAs"></infor-line>
        </div>
      </folding>
      
      <folding title="银行账号" @feedback="setIsShowType" :is-add="false">
        <div class="normal-info" @click="toBank()">
          <infor-line title="开户银行名称" :important="true" v-bind:value="bankv"></infor-line>
          <infor-line title="分/支行" v-bind:value="bnkVal.rsBranchNm"></infor-line>
          <infor-line title="银行账号" :important="true" v-bind:value="bnkVal.accountEcId"></infor-line>
          <infor-line title="账户名称" :important="true" v-bind:value="bnkVal.accountName"></infor-line>
        </div>
      </folding>

      
      <folding title="个人及配偶设立信息" @feedback="setIsShowType" :is-add="true" where-is="chigu" v-if="bsinfo.platLx== '10'">
        <div  v-for="(item) in chiguVal" class="repeat-info" v-bind:key="item" @click="toChigu(item)">
          <infor-line title="公司名称" v-bind:value="item.cCompany"></infor-line>
          <infor-line title="任职情况" v-bind:value="item.cHireRzqk"></infor-line>
          <infor-line title="本人持股" v-bind:value="item.cHireBrChigu"></infor-line>
          <infor-line title="配偶持股" v-bind:value="item.cHirePoChigu"></infor-line>
          <infor-line title="与奥克斯业务往来" v-bind:value="item.cHireIsRealAux == 'Y' ? '有' : (item.cHireIsRealAux == 'N' ? '无' : '') "></infor-line>
        </div>
      </folding>
    </div>
  </keep-alive>
</template>

<script>
  import Folding from './common/Folding'
  import InforLine from '../../../components/basic/InforLine'
  import {getQrmsg,getEdu,getOutf,getDicItem,getChigu,getExwork,getJyxy, getTrain,getLan,getPcAb,getjc,getFam,getTacp,getBnkacc,getzgzs,getsbg,getCountry,getNation,getBank} from '../../../api/api'
  import {json2Form} from '../../../util/http'

  export default {
    name: 'user-info',
    data() {
      return {
        
        bsinfo:  {},
        foldingIndex: -1,
        isFirst: true,
        foldings:[],
        eduif: [],
        sexVal: [],
        expwVal: [],
        outf: {unload:true},
        jyxy: {unload:true},
        chiguVal: [],
        lanVal: [],
        famVal: [],
        bankv: '',
        bnkVal: [],
        zgzVal: [],
        empid: '',
        routerLink: ''
      }
    },
    components: {
      Folding,
      InforLine
    },
    created() {
      this.empid = this.$store.state.hid
      this.getBsInfo()
    },
    async mounted() {
      await this.$nextTick()
      this.foldings = this.$children.filter(value => value.hasOwnProperty('isShow'))
      this.setIsShowType();
      this.routerLink = 'InformationCollection'
    },
    methods: {
      getBsInfo() {
        if(!this.empid) {
          alert("请重新登录");
          this.$router.push({path:'/hireLogin'})
          return
        }
        let params = {rsHireId: this.empid}
        getQrmsg(params).then(res => {
          if (res && res.retCode === '000000') {
            if(res.retData.cSchool == '其他') {
              res.retData.cSchool = res.retData.schoolOth ? res.retData.schoolOth : res.retData.cSchool;
            }
            this.bsinfo = res.retData
            if(this.bsinfo.cSchoolSystem == 0) {
              this.bsinfo.cSchoolSystem = ''
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      setIsShowType(title) {
        this.whichCh(title)
        if (this.foldingIndex < 0) {
          if(this.isFirst){
            this.foldings[0].isShow = true
            this.isFirst = false
          }
        } else {
          this.foldings[this.foldingIndex].isShow = false
        }
        this.foldingIndex = this.foldings.findIndex(value => value.isShow)
      },
      //工作经历
      getExpwork() {
        let params = {rsHireId: this.empid}
        getExwork(params).then(res => {
          if (res && res.retCode === '000000') {
            this.expwVal.splice(0, this.expwVal.length)
            if(Object.prototype.toString.call(res.retData) === '[object Array]'){
              this.expwVal.push(...res.retData)
            }else{
              this.expwVal.push(res.retData)
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //获取教育经历
      getEdus() {
        let params = {rsHireId: this.empid}
        getEdu(params).then(res => {
          if (res && res.retCode === '000000') {
            this.eduif.splice(0, this.eduif.length)
            if(Object.prototype.toString.call(res.retData) === '[object Array]'){
              this.eduif.push(...res.retData)
            }else{
              this.eduif.push(res.retData)
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //职称经历
      getzgzss() {
        this.zgzVal = []
        let params = {rsHireId: this.empid}
        getzgzs(params).then(res => {
          if (res && res.retCode === '000000') {
            this.zgzVal.splice(0, this.zgzVal.length)
            if(Object.prototype.toString.call(res.retData) === '[object Array]'){
              this.zgzVal.push(...res.retData)
            }else{
              this.zgzVal.push(res.retData)
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //语言能力
      getLans() {
        this.lanVal = []
        let params = {rsHireId: this.empid}
        getLan(params).then(res => {
          if (res && res.retCode === '000000') {
            this.lanVal.splice(0, this.lanVal.length)
            if(Object.prototype.toString.call(res.retData) === '[object Array]'){
              this.lanVal.push(...res.retData)
            }else{
              this.lanVal.push(res.retData)
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //亲属信息
      getFams() {
        let params = {rsHireId: this.empid}
        getFam(params).then(res => {
          if (res && res.retCode === '000000') {
            this.famVal.splice(0, this.famVal.length)
            if(Object.prototype.toString.call(res.retData) === '[object Array]'){
              this.famVal.push(...res.retData)
            }else{
              this.famVal.push(res.retData)
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //持股信息
      getChigus() {
        let params = {rsHireId: this.empid}
        getChigu(params).then(res => {
          if (res && res.retCode === '000000') {
            this.chiguVal.splice(0, this.chiguVal.length)
            if(Object.prototype.toString.call(res.retData) === '[object Array]'){
              this.chiguVal.push(...res.retData)
            }else{
              this.chiguVal.push(res.retData)
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //银行信息
      getBnkaccs() {
        let params = {rsHireId: this.empid}
        getBnkacc(params).then(res => {
          if (res && res.retCode === '000000') {
            this.bnkVal = res.retData
            this.getBanklb(res.retData.bankCd)
            if(res.retData == ''){
              this.$router.push({path:'/inputInformation/bank'})
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //档案信息
      getOutfs() {
        let params = {rsHireId: this.empid}
        getOutf(params).then(res => {
          if (res && res.retCode === '000000') {
            if(res.retData){
              this.outf = res.retData
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //敬业协议
      getJyxys() {
        let params = {rsHireId: this.empid}
        getJyxy(params).then(res => {
          if (res && res.retCode === '000000') {
            if(res.retData){
              this.jyxy = res.retData
            }
          } else {
            alert(res.retMsg);
          }
        })
      },
      //银行
      getBanklb(valbnk) {
        getBank().then(res => {
          res.retData.forEach((val) => {
            if(val.bankCd == valbnk){
              this.bankv = val.descrshort
            }
          });
        })
      },
      whichCh(val) {
        switch (val)
        {
          case '基本信息':
            if(this.bsinfo.length == 0){
              this.getBsInfo()
            }
          break;
          case '工作经历':
            if(this.expwVal.length == 0){
              this.getExpwork()
            }
          break;
          case '教育经历':
            if(this.eduif.length == 0){
              this.getEdus()
            }
          break;
          case '档案信息':
          if(this.outf.unload){
            this.getOutfs()
          }
          break;
          case '竞业协议信息':
          if(this.jyxy.unload){
            this.getJyxys()
          }
          break;
          case '职称经历':
          if(this.zgzVal.length == 0){
            this.getzgzss()
          }
          break;
          case '外语能力':
          if(this.lanVal.length == 0){
            this.getLans()
          }
          break;
          case '亲属信息':
          if(this.famVal.length == 0){
            this.getFams()
          }
          break;
          case '银行账号':
          if(this.bnkVal.length == 0){
            this.getBnkaccs()
          }
          break;
          case '个人及配偶设立信息':
          if(this.chiguVal.length == 0){
            this.getChigus()
          }
          break;
        }
      },
      //跳转基本信息
      toBasic(whch) {
        this.$router.push({  
          name:'basicIpt',  
          params:{  
            bsifs: this.bsinfo,
            whc: whch
          }  
        }) 
      },
      //工作经历
      toWorkExp(item) {
        this.$router.push({
          name:'theCompanyBefore',  
          params:{ 
            workexp: item
          } 
        })
      },
      //教育经历
      toEdu(item){
        this.$router.push({
          name:'education',  
          params:{ 
            edult: item
          } 
        })
      },
      //档案
      toOutf() {
        if(!this.outf.rsHireId) {
          this.outf.rsHireId = this.empid
        }
        this.$router.push({
          name:'outf',  
          params:{ 
            outf: this.outf
          } 
        })
      },
      //竞业协议
      toJyxy() {
        if(!this.jyxy.rsHireId) {
          this.jyxy.rsHireId = this.empid
        }
        this.$router.push({
          name:'jyxy',  
          params:{ 
            jyxy: this.jyxy
          } 
        })
      },
      //职称经历
      toquality(item) {
        this.$router.push({
          name:'qualification',  
          params:{ 
            qualt: item
          } 
        })
      },
      //语言能力
      toLang(item) {
        this.$router.push({
          name:'language',  
          params:{ 
            lang: item
          }
        })
      },
      //跳转计算机
      toChigu(item) {
        this.$router.push({
          name:'chigu',  
          params:{ 
            chigu: item
          } 
        })
      },
      //家庭
      toFamily(item) {
        this.$router.push({
          name:'family',  
          params:{ 
            fam: item
          } 
        })
      },
      //联系方式
      toContact() {
        this.$router.push({  
          name:'contactIpt',  
          params:{  
            bsifs: this.bsinfo
          }  
        }) 
      },
      toBank(){
        this.$router.push({
          name:'bank',  
          params:{ 
            banklt: this.bnkVal
          } 
        })
      },
      //判断是否数组
      ObjToArr(val,arr) {
        arr = []
        if(Object.prototype.toString.call(val) ==='[object Array]'){
          arr.push(...val)
        }else{
          arr.push(val)
        }
      }
    },
    // filters: {
    //   findLanLv(lanlv,lanlvArr=[]) {
    //     if (lanlv && lanlvArr.length > 0) {
    //       return lanlvArr.find(val => val.value === lanlv) ? lanlvArr.find(val => val.value === lanlv)['name'] : ''
    //     }
    //     return ''
    //   }
    // }
  }
</script>

<style type="text/scss" lang="scss" scoped>
  @import "./style";
</style>
